﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Prism.ViewModel;
using Microsoft.Practices.Prism.Commands;
using System.Windows;

namespace FridgeManagerApp
{
    public class MainWindowViewModel : NotificationObject
    {
        MainWindow gMainWindow = null;

        public MainWindowViewModel(Window pWindow)
        {
            gMainWindow = (MainWindow)pWindow;
        }

        protected DelegateCommand<object> loginCommand;
        public DelegateCommand<object> LoginCommand
        {
            get
            {
                return loginCommand ?? (loginCommand = new DelegateCommand<object>(ExecuteLoginCommand, CanExecuteLoginCommand));
            }
        }

        private void ExecuteLoginCommand(object obj)
        {
            ParentWindow parentWindow = new ParentWindow();
            ParentWindowViewModel mainWindowViewModel = new ParentWindowViewModel(parentWindow);
            parentWindow.DataContext = mainWindowViewModel;
            parentWindow.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
            parentWindow.Show();

            gMainWindow.Close();
        }

        private bool CanExecuteLoginCommand(object arg)
        {
            return true;
        }

        protected DelegateCommand<object> quitCommand;
        public DelegateCommand<object> QuitCommand
        {
            get
            {
                return quitCommand ?? (quitCommand = new DelegateCommand<object>(ExecuteQuitCommand, CanExecuteQuitCommand));
            }
        }

        private void ExecuteQuitCommand(object obj)
        {
            gMainWindow.Close();
        }

        private bool CanExecuteQuitCommand(object arg)
        {
            return true;
        }
    }
}
